package com.project806.Module;

import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.project806.Util.CleanDataUtils;

import javax.annotation.Nonnull;

public class CacheModule extends ReactContextBaseJavaModule {
    public CacheModule(@Nonnull ReactApplicationContext reactContext) {
        super(reactContext);
    }

    @Nonnull
    @Override
    public String getName() {
        return "CacheModule";
    }

    @ReactMethod
    public void getCache(Callback successCallback) throws Exception {
        String cache = CleanDataUtils.getTotalCacheSize(getReactApplicationContext());
        successCallback.invoke(cache + "");
    }

    @ReactMethod
    public void clearCache() {
        CleanDataUtils.clearAllCache(getReactApplicationContext());
    }
}
